#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
char map[30][30];
bool walked[30][30] = { false };
int cnt = 0;
int W, H;
int res = 1;
void dfs(int x, int y)
{
	int dx[] = { 0,1,0,-1,0 };
	int dy[] = {0,0,1,0,-1 };
	for (int i = 1; i <= 4; i++)
	{
		int nx = x + dx[i];
		int ny = y + dy[i];
		if (nx<1 || nx>W || ny<1 || ny>H)continue;
		if (map[ny][nx] == '#'|| walked[ny][nx] == true)continue;
		res++;
		walked[ny][nx] = true;
		dfs(nx, ny);
	}
}
int main()
{
	int x=0,y=0;
	scanf("%d%d", &W, &H);
	for (int i = 1; i <= H; i++)
	{
		scanf("%s", map[i]);
	}
	for (int i = 1; i <= H; i++)
	{
		for (int j = 1; j <= W; j++)
		{
			if (map[i][j] == '@')
			{
				walked[i][j] = true;
				x = j;
				y = i;
			}
		}
	}

	/*printf("\n");
	for (int i = 1; i <= H; i++)
	{
		for (int j = 1; j <= W; j++)
		{
			printf("%c", map[i][j]);
		}
		printf("\n");
	}
	printf("\n");*/


	dfs(x, y);
	printf("%d", res);
	return 0;
}